﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace Bing.Toolkit.Utility
{
    public struct Express
    {
        /// <summary>
        /// 身份证验证
        /// </summary>
        public const string IDCARD = @"^[1-9]([0-9]{16}|[0-9]{13})[xX0-9]$";
        /// <summary>
        /// 手机验证(不包含小灵通)
        /// </summary>
        public const string HANDSET = @"^13[0-9]{1}[0-9]{8}|^15[9]{1}[0-9]{8}";
        /// <summary>
        /// IP验证
        /// </summary>
        public const string IP = @"^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$";

        public const string EMAIL = @"^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$";
        /// <summary>
        /// 是否为数字
        /// </summary>
        public const string NUMBER = @"^\d+$";
        /// <summary>
        /// 是否为英文
        /// </summary>
        public const string ENGLISH = @"^[A-Za-z]+$";
        /// <summary>
        /// 是否为英文小写
        /// </summary>
        public const string LOWER = "@^[a-z]+$";
        /// <summary>
        /// 是否为英文大写
        /// </summary>
        public const string UPPER = "@^[A-Z]+$";
        /// <summary>
        /// 是否为中文
        /// </summary>
        public const string CHINESE = @"^[\u0391-\uFFE5]+$";
        /// <summary>
        /// 是否为英文或数字
        /// </summary>
        public const string ENGLISHORDIGITAL = @"^[a-zA-Z0-9]+$";

        /// <summary>
        /// 校验
        /// </summary>
        /// <param name="express">表达示</param>
        /// <param name="input">要校验的字符串</param>
        /// <returns></returns>
        public static Boolean Verify(String express, String input)
        {
            var rex = new Regex(express);

            return rex.IsMatch(input);
        }
    }
}
